﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using App.MVC.Extend;
using Microsoft.Ajax.Utilities;

namespace App.MVC.App_Start
{
    public static class SiteInfo
    {
        /// <summary>
        /// 用户名到Cookies
        /// </summary>
        /// <param name="str"></param>
        //  [System.Obsolete("SetUserId")]
        public static void SetUserName(this String str)
        {
            CookieHelper.SetCookie("schoolusername", str);
        }

        public static void SetUserId(this String str)
        {
            CookieHelper.SetCookie("schooluserid", str);
        }
        /// <summary>
        /// 姓名存到Cookies
        /// </summary>
        /// <param name="str"></param>
        public static void SetUserXingMing(this String str)
        {
            CookieHelper.SetCookie("schoolXingMing", str);
        }
        /// <summary>
        /// 权限树存入Cookie
        /// </summary>
        /// <param name="str"></param>
        public static void SetTrees(this String str)
        {
            CookieHelper.SetCookie("Trees", str);
        }
        /// <summary>
        /// 从Cookie中读取权限树
        /// </summary>
        /// <returns></returns>
        public static string GetTrees()
        {
            if (CookieHelper.GetCookieValue("Trees") != null)
            {
                return CookieHelper.GetCookieValue("Trees");
            }
            else
            {
                return string.Empty;
            }
        }
        //public static void SetCompanyId(string str)
        //{
        //    CookieHelper.SetCookie("UserId", str);
        //}
        /// <summary>
        /// 获取用户名
        /// </summary>
        /// <returns></returns>
        public static string GetUserName()
        {
            if (CookieHelper.GetCookieValue("schoolusername") != null)
            {
                return CookieHelper.GetCookieValue("schoolusername");
            }
            else
            {
                return string.Empty;
            }
        }

        public static string UserId
        {
            get { return CookieHelper.GetCookieValue("schooluserid"); }
        }

        /// <summary>
        /// 获取用户真实姓名
        /// </summary>
        /// <returns></returns>
        public static string GetXingMing()
        {
            if (CookieHelper.GetCookieValue("schoolXingMing") != null)
            {
                return CookieHelper.GetCookieValue("schoolXingMing");
            }
            else
            {
                return string.Empty;
            }
        }

    }
}